﻿using System;
using System.ComponentModel;
using System.Drawing;
using BitmapTagger;
using System.Windows.Media;
using BrainTechLLC;
using BrainTechLLC.FilterExtensions;

namespace ImageAppDataModels
{
    public interface IHasThumbnail : INotifyPropertyChanged
    {
        event EventHandler ThumbnailSet;
        Bitmap Thumbnail { get; set; }
        Bitmap ThumbnailCached { get; set; }
        void Release(ReleaseOptions options);
        SingleThumbnail GetThumbnail(LoadOptions loadOptions, Action<FileImage, SingleThumbnail> callback, bool needThumbBytes);            
    }

    public interface IHasImageBytes : INotifyPropertyChanged
    {
        byte[] ImageBytes { get; set; }
        byte[] ImageBytesCached { get; set; }
    }

    public interface IAttachedInfo : INotifyPropertyChanged
    {
        string ImageDescription { get; }
        URational Aperture { get; }
        string Artist { get; }
        Rational Brightness { get; }
        DateTime? PhotoDateTime { get; }
        string Model { get; }
        ushort? MeteringMode { get; }
        string Make { get; }
        ushort? SensingMethod { get; }
        Rational ShutterSpeed { get; }
        string Software { get; }
        string UserComment { get; }
        ushort? LightSource { get; }
        ushort? ISOSpeedRatings { get; }
        URational ExposureTime { get; }
        URational FNumber { get; }
        ushort? ExposureProgram { get; }
        DateTime? DateTimeOriginal { get; }
        DateTime? DateTimeDigitized { get; }
        string Copyright { get; }
    }

    public interface IAdditionalImageInfo : IAttachedInfo
    {
    }

    public interface IHasImageSource : INotifyPropertyChanged
    {
        ImageSource ImageSource { get; set; }
        ImageSource ImageSourceCached { get; }
        void MarkImageSourceDirty();
        ImageSource GetImageSource(int width, int height, Action<FileImage> callback);
        double ImageSourceWidth { get; set; }
        double ImageSourceHeight { get; set; }
    }

    public interface IHasBitmap : INotifyPropertyChanged
    {
        void OnThumbnailSet(SingleThumbnail thumb);
        long FileSize { get; set; }
        DateTime CreationTime { get; set; }
        DateTime CreationTimeNoLoad { get; set; }
        DateTime GetFileSizeAndCreationTime();
        Bitmap Bitmap { get; set; }
        Bitmap BitmapCached { get; set; }
        bool BitmapLoaded { get; }
        Bitmap EnsureBitmapLoaded();
        double AspectRatio { get; }
        int OriginalBitmapWidth { get; set; }
        int OriginalBitmapHeight { get; set; }
    }

    public interface IHasMD5Hash : INotifyPropertyChanged
    {
        string MD5Hash { get; set; }
        string MD5HashCached { get; }
    }

    public interface ICanBeFiltered : INotifyPropertyChanged
    {
        FilterCollection Filters { get; set; }
    }

    public interface IHasFileBackingStore : INotifyPropertyChanged
    {
        bool Delete();
        string FileName { get; set; }
        bool Deleted { get; }
        void Rename(string newName);
    }    

    public interface IAdditionalImageMeasurements
    {
        double GetBlur(bool makeCopies);
        double Similarity(IFileImage f2, int maxWidth, int maxHeight, bool makeCopies);
    }

    public interface IFileImage :
        ICanBePreloaded<Bitmap>,
        IHasFileBackingStore,
        ICanBeFiltered,
        IHasMD5Hash,
        IHasBitmap,
        IHasImageSource,
        IHasThumbnail,
        IHasImageBytes,
        IAdditionalImageMeasurements,
        INotifyPropertyChanged
    {
        void DetachEvents();
        void AttachEvents();

        void MarkEverythingDirty(bool clearThumb);
        IAdditionalImageInfo ImageInfo { get; }
        IAdditionalImageInfo ImageInfoCached { get; }
        void ClearImageInfo();

        ICoreDataProvider DataProvider { get; set; }
    }
}
